package com.trace.meat.controller;

import com.trace.meat.entity.Breeder;
import com.trace.meat.entity.Butcher;
import com.trace.meat.entity.Lic;
import com.trace.meat.service.LicService;
import org.springframework.data.relational.core.sql.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Lic)表控制层
 *
 * @author makejava
 * @since 2021-06-19 11:17:27
 */
@RestController
@RequestMapping("lic")
public class LicController {
    /**
     * 服务对象
     */
    @Resource
    private LicService licService;

    /**
     * 通过主键查询单条数据
     *
     * @param lid 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Lic selectOne(Integer lid) {
        return this.licService.queryById(lid);
    }
    /**
     * 新增数据
     */
    //http://127.0.0.1:11451/lic/insertOne?eid=101&serNum=1&licType=1&licState=1 error
    //http://127.0.0.1:11451/lic/insertOne?eid=1&serNum=1&licType=1&licState=1
    @GetMapping("insertOne")
    public Lic insert(Integer eid, String serNum, Integer licType, Integer licState) {
        Lic lic=new Lic();
        lic.setEid(eid);
        lic.setSerNum(serNum);
        lic.setLicType(licType);
        lic.setLicState(licState);
        return this.licService.insert(lic);
    }
    /**
     * 更新数据
     *
     * @param lid 主键
     * @param eid 企业id
     * @param serNum
     * @param licType
     * @param licState
     * @return 单条数据
     */
    //http://127.0.0.1:11451/lic/updateOne?lid=2&eid=3
    @GetMapping("updateOne")
    public Lic update(Integer lid, Integer eid, String serNum,Integer licType,Integer licState) {
        Lic lic=new Lic();
        lic.setLid(lid);
        lic.setEid(eid);
        lic.setSerNum(serNum);
        lic.setLicType(licType);
        lic.setLicState(licState);
        return licService.update(lic);
    }
    /**
     * 删除数据
     *
     * @param lid 主键
     * @return 是否删除了数据的布尔值
     */
    //http://127.0.0.1:11451/lic/deleteOne?lid=2
    @GetMapping("deleteOne")
    public boolean deleteById(Integer lid) {
        return licService.deleteById(lid);
    }

}
